<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>服务增加或修改页面</title>
	<link rel="stylesheet" href="../../../../res/layui/css/layui.css" media="all">
	<script src="../../../../res/js/jquery-3.1.1.min.js" type="text/javascript"
			charset="utf-8"></script>
	<script type="text/javascript" src="../../../../res/js/login_common.js"></script>
	<script src="../../../../res/layui/layui.js" charset="utf-8"></script>
	<script src="../../../../res/js/Tools.js"></script>

	<script>
        $.ajaxSetup({
            async: false
        });
	</script>
</head>
<body>
<!--<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>添加新闻</legend>
</fieldset>-->

<form class="layui-form" lay-filter="example" action="" id="formDId"  method="post" enctype="multipart/form-data">
	<input type="hidden" name="orId" id="orId">

	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label">业务员名字:</label>
			<div class="layui-input-inline">
				<input type="text" style="width: 260px" id="orFwname" class="layui-input">
			</div>
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label">业务员电话</label>
			<div class="layui-input-inline">
				<input type="text"  style="width: 260px" id="orPhoneOne"  autocomplete="off" class="layui-input">
			</div>
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label">业务员提成</label>
			<div class="layui-input-inline">
				<input type="text" style="width: 260px" id="scbMoney"  placeholder="请输入业务员提成" autocomplete="off" class="layui-input">
			</div>
		</div>
	</div>

	<div class="layui-form-item">
		<div class="layui-input-block">
			<button type="submit" class="layui-btn site-demo-active" lay-submit="" lay-filter="demo1">立即提交</button>
			<button type="reset" class="layui-btn layui-btn-primary layui-bg-red">重置按钮</button>
		</div>
	</div>
</form>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var form=null;
    layui.use('form', function() {
        form = layui.form;
        //监听提交
        form.on('submit(demo1)', function (data) {
            var ide = getQueryString("id");

            // 单击之后提交按钮不可选,防止重复提交
            var DISABLED = 'layui-btn-disabled';
            // 增加样式
            $('.site-demo-active').addClass(DISABLED);
            // 增加属性
            $('.site-demo-active').attr('disabled', 'disabled');
            var formData = new FormData(document.getElementById("formDId"));
            var loadIndex =layer.load();
            var url = "../../../../dkm.dkmproject/serviceTb/addorUpdate";
            $.ajax({
                url: url,
                type: "post",
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function (obj) {
                    if (obj.num >0) {
                        layer.msg(obj.msg, {
                            icon: 1,
                            time: 1000 //1秒关闭(如果不配置默认三秒)
                        }, function () {
                            layer.close(loadIndex);
                            //关闭当前层
                            //当你在iframe页面关闭自身时
                            parent.layui.table.reload("test");
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            //刷新父页面

                            //parent.location.reload();
                        });
                        return false;
                    }else{
                        layer.msg(obj.msg);
                        layer.close(loadIndex);
                        return false;
                    }
                },
                error: function (e) {
                    layer.msg("错误！！");
                }
            });
            return false;
        });
    })

    //修改操作
    var ide = getQueryString("id");

    if(ide) {
        findById();//修改页面的赋值

    }
    //修改页面的赋值
    function findById(){
        var id=getQueryString("id");
        var url="../../../../dkm.dkmproject/orderTb/findById";
        var data={orId:id};
        $.post(url,data,function(obj){
            $("#orId").val(obj.orId);
            $("#orPhoneOne").val(obj.orPhoneOne);
            $("#orFwname").val(obj.orFwname);
        },"json");

    }
</script>


</body>
</html>